<?php
header("Access-Control-Allow-Origin:*");

$_username = $_POST["username"];
$_password = $_POST["password"];

  
 $conn = mysqli_connect("localhost", "root", "root", "bestcake");

	// SQL
	$sql = "INSERT INTO user (username, password) VALUES ('$_username', '$_password')";
	// 执行SQL
	$result = mysqli_query($conn, $sql);
	// 判断执行结果
	if ($result){
		$arr = array("res_code"=>1, "res_message"=>"success");
		echo json_encode($arr);
	}
	else{
		$arr = array("res_code"=>-1, "res_message"=>"failed：" . mysqli_error($conn));
		echo json_encode($arr);
	}

	// 关闭数据库连接
	mysqli_close($conn); 

?>